﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.Mvc;
using System.Net;
using BI.CF.Model;
using BI.CF.BLL;
using System.Text;

namespace BI.CF.Company.Controllers
{
    public class HomeController : Controller
    {
        //
        // GET: /Home/
        #region 重写BulletinBLL            
        BulletinBLL bll = new BulletinBLL();
        #endregion
        #region  首页
        /// <summary>
        /// 首页
        /// </summary>
        /// <returns></returns>
        public ActionResult Index()
        {
            return View();
        }
        #endregion
        #region 根据名称查询广告ID      
        /// <summary>
        /// 根据名称查询广告ID
        /// </summary>
        /// <param name="name"></param>
        /// <returns></returns>
        public int BulletinIDshow(string name)
        {
            int i = Convert.ToInt32(bll.BulletinIDshow(name));
            Session["id"] = i;
            return i;
        }
        #endregion
        #region 广告显示
        /// <summary>
        /// 广告显示
        /// </summary>
        /// <returns></returns>
        public string BulletinShowOneDo(int tid)
        {
            StringBuilder str = new StringBuilder();
            str.Append("<div class=\"New_Notice Same lf\"><h2>");
            List<BulletinModel> list = bll.BulletinShowOne(tid);
            str.Append("<a href=\"#\">" + list[0].PT_Name + "</a></h2><ul> ");
            foreach (var item in list)
	        {
                //str.Append("<a href=\"/disclosure/bulletin\">" + item.PT_Name + "</a></h2>");
                str.Append("<li><a  target=\"_blank\" onclick=\"SelsetID($(this).html())\" href='/Home/BulletinContentShowOneDo?id=" + item.BulletinID + "'>" + item.B_Tile + " </a></li>");
	        }
            str.Append("</ul></div>");
            return str.ToString();
        }
        #endregion
        #region BulletinShowTwoDo   
        public string BulletinShowTwoDo(int tid)
        {
            StringBuilder str = new StringBuilder();
            str.Append("<div class=\"Media_Bd Same lf\"><h2>");
            List<BulletinModel> list = bll.BulletinShowOne(tid);
            str.Append("<a href=\"#\">" + list[0].PT_Name + "</a></h2><div class=\"Same_pic lf\"><a href=\"#\"><img src=\"/pc/resources/img/17021016222356191247660219094978.png\"title=" + list[0].B_Tile + "  alt=" + list[0].B_Tile + " /></a>" + list[0].B_Tile + " </div>");
            str.Append("<ul class=\"lf\">");
            foreach (var item in list)
            {
                str.Append("<li><a title=" + item.B_Tile + " onclick=\"SelsetID($(this).html())\" href='/Home/BulletinContentShowOneDo?id=" + item.BulletinID + "'>" + item.B_Tile + "</a></li>");
            }
            str.Append("</ul></div class=\"clear\"></div></div>");
            return str.ToString();
        }
        #endregion
        #region BulletinShowThreeDo
        public string BulletinShowThreeDo(int tid)
        {
            StringBuilder str = new StringBuilder();
            str.Append("<div class=\"Bbs_Dt Same lf\"><h2>");
            List<BulletinModel> list = bll.BulletinShowOne(tid);
            str.Append("<a href=\"#\">" + list[0].PT_Name + "</a></h2><ul>");
            foreach (var item in list)
            {
                //str.Append("<a href=\"/disclosure/bulletin\">" + item.PT_Name + "</a></h2>");
                str.Append(" <li><a target=\"_blank\" title=" + item.B_Tile + " onclick=\"SelsetID($(this).html())\" href='/Home/BulletinContentShowOneDo?id=" + item.BulletinID + "'>" + item.B_Tile + "</a></li>");
            }
            str.Append("</ul></div>");
            return str.ToString();
        }
        #endregion

        public string BulletinShowFourDo(int tid)
        {
            StringBuilder str = new StringBuilder();
            str.Append("<div class=\"Hl_Story Same lf\"><h2>");
            List<BulletinModel> list = bll.BulletinShowOne(tid);
            str.Append(" <a href=\"#\"> " + list[0].PT_Name + "</a></h2><div class=\"Same_pic  lf\"><a target=\"_blank\" title=" + list[0].B_Tile + "  href=\"#\"><img src=\"/pc/resources/img/16030113294732301498910219694504.png\" alt=" + list[0].B_Tile + "  /></a></div>");
            str.Append("<ul class=\"lf\">");
            foreach (var item in list)
            {
                str.Append("<li><a target=\"_blank\" title=" + item.B_Tile + " onclick=\"SelsetID($(this).html())\" href='/Home/BulletinContentShowOneDo?id=" + item.BulletinID + "'>" + item.B_Tile + "</a></li>");
            }
            str.Append("</ul></div class=\"clear\"></div></div>");
            return str.ToString();
        }

        /// <summary>
        /// 最新公告详细显示视图
        /// </summary>
        /// <returns></returns>
        public ActionResult BulletinContentShowOneDo(int id)
        {
            BulletinModel m = bll.BulletinContentShow(id);
            return View(m);
        }
        
        /// <summary>
        /// 修改浏览数量
        /// </summary>
        /// <param name="id"></param>
        /// <returns></returns>
        public bool BulletinUpdatePV(int id)
        {
            return bll.BulletinUpdatePV(id);
        }
    }
}
